import {
  GiftOutlined,
  HomeOutlined,
  PicRightOutlined,
  ShopOutlined,
  TeamOutlined,
} from "@ant-design/icons";
// import type { JSX } from "react";
// import type { MenuDataItem } from "@ant-design/pro-components";

export interface IRoute {
  path: string;
  name: string;
  // element:()=>JSX.Element;
  icon?: React.ReactNode;
  hideInMenu?: boolean;
}

export const ROUTE_KEY = {
  HOME: "home",
  MY: "my",
  ORG: "org",
  NO_ORG: "noOrg",
  COURSE: "course",
  STUDENT: "student",
  PRODUCT: "product",
  PAGE_404: "p404",//这里是因为Object.keys的会自动进行排序，数字>字符>Symbol
};

// export const ROUTE_CONFIG = [
//     {
//         key:'home',
//         path:'/home',
//         element: Home,
//         title: '首页',
//         name: '首页',
//         icon:<HomeOutlined/>
//     },
//     // {
//     //     path:'/login',
//     //     element: Login,
//     //     title: '登录',
//     //     name: '登录',
//     //     hideInMenu:true,
//     //     key:'login',
//     // },
//     {
//         key:'*',
//         path:'*',
//         element: Page404,
//         title: '404',
//         name: '404',
//         hideInMenu:true,
//     },
// ]

// 新版
export const ROUTE_CONFIG: Record<string, IRoute> = {
  [ROUTE_KEY.HOME]: {
    path: "home",
    // element: Home,//为了解决循环依赖
    name: "首页",
    icon: <HomeOutlined />,
  },
  [ROUTE_KEY.MY]: {
    path: "my",
    // element: Home,//为了解决循环依赖
    name: "个人信息",
    hideInMenu: true,
  },
  [ROUTE_KEY.ORG]: {
    path: "org",
    name: "门店管理",
    hideInMenu: true,
    icon: <ShopOutlined />,
  },
  [ROUTE_KEY.NO_ORG]: {
    path: "noOrg",
    name: "选择门店提示",
    hideInMenu: true,
  },
  [ROUTE_KEY.COURSE]: {
    path: "course",
    name: "课程管理",
    icon: <PicRightOutlined />,
  },
  [ROUTE_KEY.STUDENT]: {
    path: "student",
    name: "学员管理",
    icon: <TeamOutlined />,
  },
  [ROUTE_KEY.PRODUCT]: {
    path: "product",
    name: "商品管理",
    icon: <GiftOutlined />,
  },
  [ROUTE_KEY.PAGE_404]: {
    path: "*",
    // element: Page404,//为了解决循环依赖
    name: "404",
    hideInMenu: true,
  },
};

export const routes = Object.keys(ROUTE_CONFIG).map((key: string | number) => {
  return { ...ROUTE_CONFIG[key], key };
});

export const getRouteByKey = (key: string) => ROUTE_CONFIG[key];
